﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IterationLife.Domains.Sports.Dtos.MTDatas;
using IterationLife.Domains.Sports.Models;
using Util;

namespace IterationLife.Domains.Sports.Dtos.SportReports
{
    /// <summary>
    /// 运动时间线数据
    /// </summary>
    public class SportTimeLineData
    {
        public SportTimeLineData(SportEventGroupPerson sportEventGroupPerson, MTGatherData mtGather)
        {
            this.Name = sportEventGroupPerson.SportAthlete.Name;
            this.SportEventId = sportEventGroupPerson.SportEventGroup.SportEventId.Value;
            this.SportUserId = sportEventGroupPerson.SportAthleteId.Value;
            this.Time = sportEventGroupPerson.SportEventGroup.SportEvent.StartTime.Value;
            this.Value = mtGather.HrAffectPercentage.SafeValue();
            this.ValueString = this.Value.ToString("##.0");
            this.HeartRateMax = mtGather.HeartRateMax == null ? null : mtGather.HeartRateMax.Value.ToString("####");
            this.HeartRateAvg = mtGather.HeartRateAvg == null ? null : mtGather.HeartRateAvg.Value.ToString("####");
            this.TotalDistance = mtGather.TotalDistance == null ? null : mtGather.TotalDistance.Value.ToString("####");
            this.SprintCount = mtGather.Speed6Times == null ? "0" : mtGather.Speed6Times.Value.ToString("####");
            this.MaxSpeed = mtGather.SpeedMax == null ? null : mtGather.SpeedMax.Value.ToString("####.0");

            this.PartnerEventId = sportEventGroupPerson.SportEventGroup.SportEvent.PartnerEventId;
            this.EventType = sportEventGroupPerson.SportEventGroup.SportEvent.EventType;
            this.PartnerUserId = sportEventGroupPerson.SportUser.PartnerUserId;
            this.PartnerAthleteId = sportEventGroupPerson.SportAthlete.PartnerAthleteId;

        }

        /// <summary>
        /// 姓名
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 比赛事件Id
        /// </summary>
        public Guid SportEventId { get; set; }
        /// <summary>
        /// 用户Id
        /// </summary>
        public Guid SportUserId { get; set; }
        /// <summary>
        /// 发生时间
        /// </summary>

        public DateTime Time { get; set; }
        /// <summary>
        /// 时间完整
        /// </summary>
        public string TimeString
        {
            get { return this.Time.ToString("yyyyMMddHHmmss"); }
        }
        /// <summary>
        /// 日期文字
        /// </summary>
        public string TimeDateString
        {
            get { return this.Time.ToString("M.d"); }
        }
        /// <summary>
        /// 日期文字
        /// </summary>
        public string TimeCnDateString
        {
            get { return this.Time.ToString("M月d日"); }
        }
        /// <summary>
        /// 单位值 - 有效锻炼时间占比（暂定）
        /// </summary>
        public decimal Value { get; set; }
        /// <summary>
        /// 值的文字显示
        /// </summary>
        public string ValueString { get; set; }
        /// <summary>
        /// 射门转化率
        /// </summary>
        public string GoalSuccessPercentage { get; set; }
        /// <summary>
        /// 传球成功率
        /// </summary>
        public string PassSuccessPercentage { get; set; }
        /// <summary>
        /// 最大心率
        /// </summary>
        public string HeartRateMax { get; set; }
        /// <summary>
        /// 平均心率
        /// </summary>
        public string HeartRateAvg { get; set; }
        /// <summary>
        /// 跑动距离
        /// </summary>
        public string TotalDistance { get; set; }
        /// <summary>
        /// 冲刺次数
        /// </summary>
        public string SprintCount { get; set; }
        /// <summary>
        /// 最高速度
        /// </summary>
        public string MaxSpeed { get; set; }


        /// <summary>
        /// 动量比赛id
        /// </summary>
        public string PartnerEventId { get; set; }
        /// <summary>
        /// 动量比赛类型
        /// </summary>
        public int EventType { get; set; }
        /// <summary>
        /// 动量用户id
        /// </summary>
        public string PartnerUserId { get; set; }
        /// <summary>
        /// 动量球员id
        /// </summary>
        public string PartnerAthleteId { get; set; }
    }
}
